package com.aserbao.aserbaosandroid.functions.database.greenDao.db;

import android.database.Cursor;
import android.database.sqlite.SQLiteStatement;

import org.greenrobot.greendao.AbstractDao;
import org.greenrobot.greendao.Property;
import org.greenrobot.greendao.internal.DaoConfig;
import org.greenrobot.greendao.database.Database;
import org.greenrobot.greendao.database.DatabaseStatement;

import com.example.odm.securitydetectionapp.module.history.bean.historyErrorMsg;

// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
/** 
 * DAO for table "HISTORY_ERROR_MSG".
*/
public class historyErrorMsgDao extends AbstractDao<historyErrorMsg, Long> {

    public static final String TABLENAME = "HISTORY_ERROR_MSG";

    /**
     * Properties of entity historyErrorMsg.<br/>
     * Can be used for QueryBuilder and for referencing column names.
     */
    public static class Properties {
        public final static Property ID = new Property(0, Long.class, "ID", true, "_id");
        public final static Property Time = new Property(1, String.class, "time", false, "TIME");
        public final static Property ErrorMsg = new Property(2, String.class, "errorMsg", false, "ERROR_MSG");
        public final static Property Address = new Property(3, String.class, "address", false, "ADDRESS");
    }


    public historyErrorMsgDao(DaoConfig config) {
        super(config);
    }
    
    public historyErrorMsgDao(DaoConfig config, DaoSession daoSession) {
        super(config, daoSession);
    }

    /** Creates the underlying database table. */
    public static void createTable(Database db, boolean ifNotExists) {
        String constraint = ifNotExists? "IF NOT EXISTS ": "";
        db.execSQL("CREATE TABLE " + constraint + "\"HISTORY_ERROR_MSG\" (" + //
                "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: ID
                "\"TIME\" TEXT," + // 1: time
                "\"ERROR_MSG\" TEXT," + // 2: errorMsg
                "\"ADDRESS\" TEXT);"); // 3: address
    }

    /** Drops the underlying database table. */
    public static void dropTable(Database db, boolean ifExists) {
        String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"HISTORY_ERROR_MSG\"";
        db.execSQL(sql);
    }

    @Override
    protected final void bindValues(DatabaseStatement stmt, historyErrorMsg entity) {
        stmt.clearBindings();
 
        Long ID = entity.getID();
        if (ID != null) {
            stmt.bindLong(1, ID);
        }
 
        String time = entity.getTime();
        if (time != null) {
            stmt.bindString(2, time);
        }
 
        String errorMsg = entity.getErrorMsg();
        if (errorMsg != null) {
            stmt.bindString(3, errorMsg);
        }
 
        String address = entity.getAddress();
        if (address != null) {
            stmt.bindString(4, address);
        }
    }

    @Override
    protected final void bindValues(SQLiteStatement stmt, historyErrorMsg entity) {
        stmt.clearBindings();
 
        Long ID = entity.getID();
        if (ID != null) {
            stmt.bindLong(1, ID);
        }
 
        String time = entity.getTime();
        if (time != null) {
            stmt.bindString(2, time);
        }
 
        String errorMsg = entity.getErrorMsg();
        if (errorMsg != null) {
            stmt.bindString(3, errorMsg);
        }
 
        String address = entity.getAddress();
        if (address != null) {
            stmt.bindString(4, address);
        }
    }

    @Override
    public Long readKey(Cursor cursor, int offset) {
        return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0);
    }    

    @Override
    public historyErrorMsg readEntity(Cursor cursor, int offset) {
        historyErrorMsg entity = new historyErrorMsg( //
            cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // ID
            cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // time
            cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // errorMsg
            cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3) // address
        );
        return entity;
    }
     
    @Override
    public void readEntity(Cursor cursor, historyErrorMsg entity, int offset) {
        entity.setID(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0));
        entity.setTime(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1));
        entity.setErrorMsg(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2));
        entity.setAddress(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3));
     }
    
    @Override
    protected final Long updateKeyAfterInsert(historyErrorMsg entity, long rowId) {
        entity.setID(rowId);
        return rowId;
    }
    
    @Override
    public Long getKey(historyErrorMsg entity) {
        if(entity != null) {
            return entity.getID();
        } else {
            return null;
        }
    }

    @Override
    public boolean hasKey(historyErrorMsg entity) {
        return entity.getID() != null;
    }

    @Override
    protected final boolean isEntityUpdateable() {
        return true;
    }
    
}
